<?php

@session_start();
if (isset($_REQUEST['delete'])) {
    $id = intval($_REQUEST['delete']);
    $count = count($_SESSION['cart']);
    if (isset($_SESSION['cart'])) {
        if ($id == 0) {
            unset($_SESSION['cart']);
        } else {
            for ($i = 0; $i < $count; $i++) {
                if ($id == $_SESSION['cart'][$i]['id']) {
                    unset($_SESSION['cart'][$i]);
                    break;
                }
            }
            $_SESSION['cart']=array_values($_SESSION['cart']);
        }
    }
   header("location:cart.php");
    exit();
}
?>
